<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Hoyi Cloud API DOC</title>
		<%# HoyiPageSBAdminLib() #%>
		<style type="text/css">
			.nopadding{
				padding: 0px;
			}

			td{
				word-wrap:break-word;
			}


		</style>
		<script type="text/javascript">
		
			 //格式化代码函数,已经用原生方式写好了不需要改动,直接引用就好
		    var formatJson = function (json, options) {
		        var reg = null,
		                formatted = '',
		                pad = 0,
		                PADDING = '    ';
		        options = options || {};
		        options.newlineAfterColonIfBeforeBraceOrBracket = (options.newlineAfterColonIfBeforeBraceOrBracket === true) ? true : false;
		        options.spaceAfterColon = (options.spaceAfterColon === false) ? false : true;
		        if (typeof json !== 'string') {
		            json = JSON.stringify(json);
		        } else {
		            json = JSON.parse(json);
		            json = JSON.stringify(json);
		        }
		        reg = /([\{\}])/g;
		        json = json.replace(reg, '\r\n$1\r\n');
		        reg = /([\[\]])/g;
		        json = json.replace(reg, '\r\n$1\r\n');
		        reg = /(\,)/g;
		        json = json.replace(reg, '$1\r\n');
		        reg = /(\r\n\r\n)/g;
		        json = json.replace(reg, '\r\n');
		        reg = /\r\n\,/g;
		        json = json.replace(reg, ',');
		        if (!options.newlineAfterColonIfBeforeBraceOrBracket) {
		            reg = /\:\r\n\{/g;
		            json = json.replace(reg, ':{');
		            reg = /\:\r\n\[/g;
		            json = json.replace(reg, ':[');
		        }
		        if (options.spaceAfterColon) {
		            reg = /\:/g;
		            json = json.replace(reg, ':');
		        }
		        (json.split('\r\n')).forEach(function (node, index) {
		                    var i = 0,
		                            indent = 0,
		                            padding = '';
	
		                    if (node.match(/\{$/) || node.match(/\[$/)) {
		                        indent = 1;
		                    } else if (node.match(/\}/) || node.match(/\]/)) {
		                        if (pad !== 0) {
		                            pad -= 1;
		                        }
		                    } else {
		                        indent = 0;
		                    }
	
		                    for (i = 0; i < pad; i++) {
		                        padding += PADDING;
		                    }
	
		                    formatted += padding + node + '\r\n';
		                    pad += indent;
		                }
		        );
		        return formatted;
		    };

			function GetCates(pgidx){
				var pdata = {
					"behavior":"GetCates",
					"pwds":getUrlParam("pwds"),
					"filter":$('#filter').val(),
					"pgidx":pgidx
				}
				HOYI_POST(pdata, function(rdata, status){
					$('#cates').empty().append(rdata);
				});
			}

			function GetAPIS(cates,pgidx){
				//curcates = cates;
				var pdata = {
					"behavior":"GetAPIS",
					"pwds":getUrlParam("pwds"),
					"pgidx":pgidx,
					"cates":cates
				}
				HOYI_POST(pdata, function(rdata, status){
					$('#APIS').empty().append(rdata);
				});
			}
			
			function showapis(tar, cates, mthname){
				var pdata = {
					"behavior":"GetReqTable",
					"pwds":getUrlParam("pwds"),
					"cates":cates,
					"mthname":mthname
				}
				HOYI_POST(pdata, function(rdata, status){
					$(tar).parent().children("div").last().html(rdata);
				});
			}
			
			function getPaging(){
				var pdata = {
					"behavior":"GetCatePag",
					"pwds":getUrlParam("pwds"),
					"filter":$('#filter').val(),
				}
				HOYI_POST(pdata, function(rdata, status){
					$('#catepaging').html(rdata);
				});
			}
			
			function req(id){
				var url = $('#request' + id).html();
				var pdata = {};
				//alert("url:" + url);
				var reqpara = "";
				$("#apibody"+ id).find('.paras').each(function(idx, item){
					
					var namex = $(item).find('.name').eq(0).html() + "";
					var value = $(item).find('.input').eq(0).val();
					pdata[namex] = encodeURI(value);
					reqpara +=  namex + "=" + encodeURI(value) + "&";
					//alert('name:' + namex + ",value:" + value);
				});
				var resultJson = formatJson(pdata);
				//$('#para'+id).html(JSON.stringify(pdata,null, '\t'));
				$('#para'+id).html('<pre>' +resultJson + '</pre>');
				reqpara = reqpara.substring(0, reqpara.length - 1);
				$('#reqpara' + id).html(reqpara);
				
				HOYI_POST_URL(url, pdata, function(rdata,status){
					//var repstr = JSON.stringify(rdata);
					var retxml = formatJson(rdata);
					// $('#response' + id).html("data:" + rdata.data +",msg:" + rdata.msg + ",status:" + rdata.status);
					$('#response' + id).html('<pre>' +retxml + '</pre>');
				})
				//alert('pdata:' + pdata);
			}
			
			function gotoindex(){
				window.location.href = "index.html?pwds=" + getUrlParam('pwds');
			}
			
			window.onload = function(){
				GetCates(1);
				getPaging();
			};
		</script>
	</head>
	<body>

		<div class="bs-example" data-example-id="default-navbar">
	    <nav class="navbar navbar-default" style="margin-bottom: 0px;">
	      <div class="container-fluid">
	        <!-- Brand and toggle get grouped for better mobile display -->
	        <div class="navbar-header">
	          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
	            <span class="sr-only">Toggle navigation</span>
	            <span class="icon-bar"></span>
	            <span class="icon-bar"></span>
	            <span class="icon-bar"></span>
	          </button>
	          <a class="navbar-brand" href="#">Hoyi Cloud APP</a>
	        </div>

	        <!-- Collect the nav links, forms, and other content for toggling -->
	        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
	          <ul class="nav navbar-nav">
	            <li style="cursor:pointer;"><a onclick="gotoindex()">API DOC <span class="sr-only">(current)</span></a></li>
	            <li class="active" style="cursor:pointer;"><a href="#">ALL API<span class="sr-only">(current)</span></a></li>
	            
	            <li class="hide"><a href="#">Link</a></li>
	            <li class="dropdown hide">
	              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
	              <ul class="dropdown-menu">
	                <li><a href="#">Action</a></li>
	                <li><a href="#">Another action</a></li>
	                <li><a href="#">Something else here</a></li>
	                <li role="separator" class="divider"></li>
	                <li><a href="#">Separated link</a></li>
	                <li role="separator" class="divider"></li>
	                <li><a href="#">One more separated link</a></li>
	              </ul>
	            </li>
	          </ul>
	          <form class="navbar-form navbar-right ">
	            <div class="form-group">
	              <input type="text" id="filter" class="form-control" placeholder="Search">
	            </div>
	            <button type="button" class="btn btn-default" onclick="GetCates(1);getPaging();">Search</button>
	          </form>
	          <ul class="nav navbar-nav navbar-right hide">
	            <li><a href="#">Link</a></li>
	            <li class="dropdown">
	              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
	              <ul class="dropdown-menu">
	                <li><a href="#">Action</a></li>
	                <li><a href="#">Another action</a></li>
	                <li><a href="#">Something else here</a></li>
	                <li role="separator" class="divider"></li>
	                <li><a href="#">Separated link</a></li>
	              </ul>
	            </li>
	          </ul>
	        </div><!-- /.navbar-collapse -->
	      </div><!-- /.container-fluid -->
	    </nav>
	  </div>

	  <div class="container-fluid">
	  	<div class="row">
	  		<div class="col-md-3 nopadding">
	  			<ul id="cates" class="nav nav-pills nav-stacked nav-pills-stacked-example">
			      <li role="presentation"  class="hide"><a href="#">Home</a></li>
			      <li role="presentation"  class="hide"><a href="#">Profile</a></li>
			      <li role="presentation" class="hide"><a href="#">Messages</a></li>
			     
			    </ul>	
		  		<div>
		  			<nav aria-label="Page navigation">
					  <ul id="catepaging" class="pagination">
					    <li class="hide"><a href="#" onclick="GetAPIS(1)">1</a></li>
					    <li class="hide"><a href="#" onclick="GetAPIS(2)">2</a></li>
					  </ul>
					</nav>
		  		</div>
	  		</div>
	  		<div id="APIS" class="col-md-9 nopadding">
  				
	  		</div>
	  	</div>
	  </div>

	</body>
</html>